//
//  DQLoginViewController.swift
//  DouQu
//
//  Created by guojianfeng on 2017/7/27.
//  Copyright © 2017年 guojianfeng. All rights reserved.
//

import UIKit

class DQLoginViewController: DQBaseViewController {
    @IBOutlet weak var loginBtn: UIButton!
    @IBOutlet weak var phoneTextField: UITextField!
    @IBOutlet weak var pwdTextField: UITextField!
    @IBOutlet weak var phoneResultUILabel: UILabel!
    @IBOutlet weak var pwdResultUILabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "登录"
        view.backgroundColor = UIColor.white
        phoneTextField.delegate = self
        pwdTextField.delegate = self
        
        phoneTextField.addTarget(self, action: #selector(DQLoginViewController.textFieldDidReChange(textField:)), for: UIControlEvents.editingChanged)
        pwdTextField.addTarget(self, action: #selector(DQLoginViewController.textFieldDidReChange(textField:)), for: UIControlEvents.editingChanged)
        
        //设置登录按钮一开始为不可点击
        loginBtn.isEnabled = false
        loginBtn.alpha = 0.6
        
        textFieldDidReChange(textField: phoneTextField)
        textFieldDidReChange(textField: pwdTextField)
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        self.view.endEditing(true)
    }
}

extension DQLoginViewController: UITextFieldDelegate{
    /**
     检测正在输入
     
     - parameter textField: textField description
     */
    @objc fileprivate func textFieldDidReChange(textField: UITextField) {
    
    }
    
}


extension DQLoginViewController{
    
    // 登录按钮的点击
    @IBAction func loginBtnClick(_ sender: UIButton) {
        print("loginBtnClick")
    }
    /**
     qq登录
     
     - parameter sender: 按钮
     */
    @IBAction func qqLogin(sender: UIButton) {
        self.view.endEditing(true)
    }
    
    
    /**
     微博登录
     
     - parameter sender: 按钮
     */
    @IBAction func weiboLogin(sender: UIButton) {
        self.view.endEditing(true)
    }
    
}
